import request from '@/router/axios';

// 设备生产计划
export const setPlanOperationTime = (data) => {
  return request({
    url: '/api/mes-product/calendar/set-plan-operation-time',
    method: 'post',
    data
  });
};

// 获取日历详情
export const getCalendarDetail = (sectionId, year) => {
  return request({
    url: '/api/mes-product/calendar/calendar-day-list',
    method: 'get',
    params: {
      sectionId,
      year
    }
  });
};

// 新增/编辑 日作业时间模板
export const submitCalendarDayTemplate = (data) => {
  return request({
    url: '/api/mes-product/calendar/submit-calendar-day-template',
    method: 'post',
    data
  });
};
// 分页查询作业日模板
export const getCalendarDayTemplateList = (current, size, params) => {
  return request({
    url: '/api/mes-product/calendar/page-query-calendar-day-template',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 删除作业日模板
export const deleteCalendarDayTemplate = (ids) => {
  return request({
    url: '/api/mes-product/calendar/delete-calendar-day-template',
    method: 'get',
    params: {
      ids
    }
  });
};

// 获取默认生产日键值对
export const getWeekdayKeyValue = () => {
  return request({
    url: '/api/mes-product/calendar/weekday-key-value',
    method: 'get'
  });
};

// 计算生产日工作时长
export const calculateWorkHour = (data) => {
  return request({
    url: '/api/mes-product/calendar/calculate-work-hour',
    method: 'post',
    data
  });
};

// 获取作业日分页列表
export const getCalendarPage = (current, size, params) => {
  return request({
    url: '/api/mes-product/calendar/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 检验是否所有工段配置日历方案
export const checkCalendar = () => {
  return request({
    url: '/api/mes-product/calendar/check/section',
    method: 'get'
  });
};
// 启用日历
export const calendarEnable = (id) => {
  return request({
    url: '/api/mes-product/calendar/enable',
    method: 'get',
    params: {
      id
    }
  });
};

// 禁用日历
export const calendarDisable = (id) => {
  return request({
    url: '/api/mes-product/calendar/disable',
    method: 'get',
    params: {
      id
    }
  });
};

// 新增&日历初始化
export const initCalendar = (data) => {
  return request({
    url: '/api/mes-product/calendar/initCalendar',
    method: 'post',
    data
  });
};

// 删除日历
export const deleteCalendar = (id) => {
  return request({
    url: '/api/mes-product/calendar/delete',
    method: 'get',
    params: {
      id
    }
  });
};

// 新增,编辑 生产日,取消生产日,特定日
export const calendarSubmitSpecialDay = (data) => {
  return request({
    url: '/api/mes-product/calendar/submit-special-day',
    method: 'post',
    data
  });
};

// 检验作业日模板时段
export const veifyCalendarDay = (data) => {
  return request({
    url: '/api/mes-product/calendar/verify-calendar-day-scheme-period-of-time',
    method: 'post',
    data
  });
};

// 保存作业日配置校验
export const calendarVerify = () => {
  return request({
    url: '/api/mes-product/calendar/save-calendar-config-verify',
    method: 'get'
  });
};

// 获取作业日工段
export const getCalendarSection = () => {
  return request({
    url: '/api/mes-product/calendar/getCalendarSection',
    method: 'get'
  });
};
